package com.pandora.interfacecore.action;

import com.pandora.common.exception.EduException;
import com.pandora.common.util.StringUtils;
import com.pandora.framework.action.BaseAction;
import com.pandora.framework.vo.ServiceCoreVO;
import com.pandora.interfacecore.adapter.DemoAdapter;
import com.pandora.interfacecore.vo.DemoVO;

/**
 * 接口Demo
 * 
 * @author JingChenglong 2018/01/20 18:30
 *
 */
public class DemoAction extends BaseAction {

	@Override
	public ServiceCoreVO execute() throws EduException {

		DemoVO vo = (DemoVO) init();

		vo = DemoAdapter.getDemoVOByName(vo);

		resObject.put("vo", vo.toString());

		return response();
	}

	@Override
	public Object initData() throws EduException {

		DemoVO vo = new DemoVO();
		vo.setName(StringUtils.nullToStrTrim(getRequestContenValue("name")));
		vo.setPhone(StringUtils.nullToStrTrim(getRequestContenValue("phone")));

		if (StringUtils.isEmpty(vo.getName())) {
			throw new EduException(130001);
		}

		return vo;
	}
}